'''
多态，子类继承父类后可以重写父类方法
'''

from abc import ABCMeta, abstractmethod

class Animal(object, metaclass=ABCMeta):
    '''动物'''

    def __init__(self, nickname):
        self._nickname = nickname

    @abstractmethod
    def make_voice(self):
        '''发出声音'''
        pass

class Dog(Animal):
    '''狗'''
    def make_voice(self):
        print('%s:汪汪汪...' % self._nickname)

class Cat(Animal):
    '''猫'''
    def make_voice(self):
        print('%s:喵喵喵...' % self._nickname)

def main():
    pets = [Dog('旺财'), Cat('凯蒂'), Dog('大黄')]
    for pet in pets:
        pet.make_voice()

if __name__ == '__main__':
    main()        